package product

import (
	"github.com/gin-gonic/gin"
	"huijing_mall/internal/database/models"
	"huijing_mall/shared/get_ctx_value"
	"huijing_mall/shared/kernel/ask"
	"huijing_mall/shared/kernel/hmErrors"
	"net/http"
)

func ListProduct(c *gin.Context) {
	//userID := get_ctx_value.GetUID(c)
	dbs := get_ctx_value.GetDBS(c)
	userACRUD := models.NewModelCRUD(models.ProductType)
	list, total, err := userACRUD.List(dbs.DB, 1, 10)
	if err != nil {
		ask.NewErrors(c, http.StatusInternalServerError, -1, hmErrors.SystemTypeErr)
		return
	}
	data := make(map[string]interface{})
	data["list"] = list
	data["total"] = total
	ask.Success(c, data)
}
